package opdracht3;

/**
 * Class to represent a buyer, these people get to walk around the show on their
 * own.
 * 
 * @author Sander & Dave
 * 
 */
public class Buyer extends Visitor {

	public Buyer(String name, Autoshow show) {
		super(name, show);
	}

	public void run() {
		while (true) {
			try {
				// The buyer is just living his life.
				justLive();
				// Reports that he wants to visit the show.
				getShow().visit();
				// buyer buys a car.
				buyCar();
				// reports he wants to leave the show.
				getShow().leave();
			} catch (InterruptedException e) {

			}
		}
	}

	/**
	 * Method that represents the buyer to wander around the show and buy a car.
	 */
	public void buyCar() {
		try {
			System.out.println(super.getName() + " looks for a car to buy.");
			Thread.sleep((int) (Math.random() * 10000));
			System.out
					.println(super.getName() + " buys $40.000 worth of cars.");
		} catch (InterruptedException e) {

		}
	}

}
